package org.bees.cms.core.content;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.bees.cms.common.Tree;

@Entity
public class Category extends Content implements Tree<Category> {
	private static final long serialVersionUID = 3589859628159837974L;

	private Set<Topic> topics = new HashSet<Topic>();
	private Set<Article> articles = new HashSet<Article>();
	private Category parent;
	private Set<Category> children = new HashSet<Category>();

	@Override
	public List<Category> ancestors() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Category> descendants() {
		// TODO Auto-generated method stub
		return null;
	}

	@OneToMany(cascade = { CascadeType.REMOVE, CascadeType.REFRESH }, mappedBy = "category")
	public Set<Topic> getTopics() {
		return topics;
	}

	public void setTopics(Set<Topic> topics) {
		this.topics = topics;
	}

	@OneToMany(cascade = { CascadeType.REMOVE, CascadeType.REFRESH }, mappedBy = "category")
	public Set<Article> getArticles() {
		return articles;
	}

	public void setArticles(Set<Article> articles) {
		this.articles = articles;
	}

	@ManyToOne(cascade = { CascadeType.REFRESH })
	@Override
	public Category getParent() {
		return parent;
	}

	@Override
	public void setParent(Category parent) {
		this.parent = parent;
	}

	@OneToMany(cascade = { CascadeType.REMOVE, CascadeType.REFRESH }, mappedBy = "parent")
	@Override
	public Set<Category> getChildren() {
		return children;
	}

	@Override
	public void setChildren(Set<Category> children) {
		this.children = children;
	}

}
